//存放文章相关的所有接口
//引入请求库
import request from '@/utils/request'

//获取文章列表接口
export const getList = function (params) {
    //返回一个promise对象
    return request({
        url: '/mp/v1_0/articles',
        method: 'GET',
        params
    })
}

//删除文章列表接口
export const delArticle = function (articleId) {
    //返回一个promise对象
    return request({
        url: `/mp/v1_0/articles/${articleId}`,
        method: 'DELETE'
    })
}

//获取频道数据
export const getChannels = function () {
    //返回一个promise对象
    return request({
        url: '/mp/v1_0/channels',
        method: 'GET'
    })
}

//添加文章的接口
export const addArticle = function (draft, data) {
    //返回一个promise对象
    return request({
        url: '/mp/v1_0/articles',
        method: 'POST',
        //放置query数据
        params: {
            draft
            // draft:draft
        },
        //放置body数据  es6简写
        data
        // data:data
    })
}


//获得指定文章的接口
export const getArticle = function (articleId) {
    //返回一个promise对象
    return request({
        url: `/mp/v1_0/articles/${articleId}`,
        method: 'GET'
    })
}


//编辑文章的接口
export const updateArticle = (isDraft, id, article) => {
    return request({
        method: 'PUT',
        url: `/mp/v1_0/articles/${id}`,
        params: {
            draft: isDraft
        },
        data: article
    })
}
